﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lumo.display.animation2D
{
    /// <summary>
    /// Wait animation.
    /// </summary>
    public class WaitAnimation2D : IInternalAnimation2D, IAnimation2D
    {
        // Private declarations.
        private float Time;
        private float CurrentTime = 0;

        /// <summary>
        /// Constructor
        /// </summary>
        public WaitAnimation2D(float Time)
        {
            // Set variables.
            this.Time          = Time;
            this.Setupped      = false;
        }

        /// <summary>
        /// Setup the object.
        /// </summary>
        /// <param name="ParentObject">The parent object</param>
        public void Setup(object ParentObject)
        {
            // Already setupped.
            if (this.Setupped)
                return;
            // Set values
            CurrentTime = 0;
            this.Setupped = true;

        }

        /// <summary>
        /// Reset the object.
        /// </summary>
        public void Reset()
        {
            this.Setupped = false;
        }

        /// <summary>
        /// Setupped check;
        /// </summary>
        public bool Setupped { get; set; }

        /// <summary>
        /// Update the animation.
        /// </summary>
        /// <param name="Game">The game</param>
        public void Update(LumoComponent Game)
        {
            // Not setupped yet.
            if (!this.Setupped)
                Setup(null);
            if (CurrentTime < Time)
            {
                CurrentTime += (float)(Game.GameTime.ElapsedGameTime.TotalMilliseconds);
                if (CurrentTime > Time)
                    CurrentTime = Time;
            }
        }

        /// <summary>
        /// Finished check.
        /// </summary>
        public bool Finished { get { return (CurrentTime >= Time); } }
    }
}
